<?php

/**
 * Project form base class.
 *
 * @package    form
 * @version    SVN: $Id: sfPropelFormBaseTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
abstract class BaseFormPropel extends sfFormPropel
{
	public function setup()
	{
		// Unset needless widgets
		unset($this['deleted_at'], $this['created_at'], $this['updated_at']);
		
                   
                
               
		// Get form formatter
		$formatter = $this->widgetSchema->getFormFormatter();
		
		// Set form formatter values
                $formatter->setRowFormat("%label%%help%\n<br class=\"nobr\">\n%field%\n%error%<br class=\"clear\">\n%hidden_fields%\n");
		$formatter->setHelpFormat('%help%');
		$formatter->setErrorRowFormat("<tr><td colspan=\"2\">\n%errors%</td></tr>\n");
		$formatter->setErrorListFormatInARow("<div class=\"error\">%errors%</div>\n");
		$formatter->setErrorRowFormatInARow("%error%");
		$formatter->setNamedErrorRowFormatInARow(" <li>%name%: %error%</li>\n");
		$formatter->setDecoratorFormat("<div>\n %content%</div>");
		
		$this->setStarForRequiredFileds();
	       $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('catalogue');
	}

    public function setStarForRequiredFileds()
	{
		$helpFormat = '%s';
		foreach ($this->widgetSchema->getPositions() as $widget)
		{
			
                        $this->validatorSchema[$widget]->getOption('required') === true ?
			$this->widgetSchema->setHelp($widget, sprintf($helpFormat, '*')) :
			$this->widgetSchema->setHelp($widget, sprintf($helpFormat, '&nbsp;'));
		}
	}
}
